package com.shineoxygen.common.base.alipay.directpay.config;

import java.io.IOException;
import java.util.Properties;

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.springframework.context.annotation.Configuration;

import com.saysth.commons.utils.PropertiesUtils;

/**
 * 
 * @author 王辉阳
 * @date 2016年11月18日 下午6:11:10
 * @Description 设置支付宝即时到账接口帐户有关信息及返回路径
 * 
 *              需配置properties，参照同目录下的backup.properties
 */
@Configuration
public class AlipayConfig {
	private static Logger logger = LogManager.getLogger(AlipayConfig.class);
	// 合作身份者ID，签约账号，以2088开头由16位纯数字组成的字符串，查看地址：https://b.alipay.com/order/pidAndKey.htm
	public static String partner = "2088521294284913";

	// 收款支付宝账号，以2088开头由16位纯数字组成的字符串，一般情况下收款账号就是签约账号
	public static String seller_id = partner;

	// 商户的私钥,需要PKCS8格式，RSA公私钥生成：https://doc.open.alipay.com/doc2/detail.htm?spm=a219a.7629140.0.0.nBDxfy&treeId=58&articleId=103242&docType=1
	public static String private_key = "MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBANwFz0KkVk7u0yN5209Su8SdOrRDTDVZFn2eKzzuZl5PsVm0rktjGh4c6PVWvopYzLJF1AMgdqM3oaGjttoVp0u/9zYfax7YNkFVjrRjXV+9lKzZ+ecklfx27sfOetOQZmk1JZ5jjbLWlA1VJbS11nre5NIcxWLb5F3vyNhLmvT/AgMBAAECgYB6RuhGuxoUR/ojbyeI0Av2WwMzB2ulAlvTeEHDXSKbK2L+3cE3uF3demelYY4HSQ6JzPDkw/frAZHcSSXn0bzk/ivloNQs7ayzDyhRlGGjbdYKe/nDuhCgxQp8Q51r5gLRDEUKhAYS3uY0bKd/J9W603+M1gJplLDhb58Mg/pG8QJBAPmLTyrKk74sW8k73PhEWZ3gaN5bmlppDQs9RuW250vnMHRCQtgbnp7dq4IZtIdAns/BZrERrTfKt1LNNL+StpUCQQDhtvv+lMdsWPqJcjn/jL7/NQPv5IhzYeXV+Qv29y4EqDhEk9t1vJ6JNbuznXC3ag1OyayxRwxlUQIU2OqAcXxDAkBYrGAdXI7TbP/Qqi0DK4aMy0l4eiSHK/0umT+wMSZPmn9lUIZgNLBQ04Q2Xtv/k77bJGZRVW6v/KDYE4NC7+dhAkEAwIDljoypQJjqpErNeEw7oUE/6FtKnM2Dzegn8iuCDerCgopwA4wo0fEH8vp15ZgHXYjXRiLISai7U7hk18LyLQJBAPJ1VrjKS9AKKJefo8MeoFwn4MKnDjxFUNu+EKXCeTvA7TkcVF+uupSCv5MQphXaQEXpKA5RtMDxskBVOk+MUEw=";

	// 支付宝的公钥,查看地址：https://b.alipay.com/order/pidAndKey.htm

	public static String alipay_public_key = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCnxj/9qwVfgoUh/y2W89L6BkRAFljhNhgPdyPuBV64bfQNN1PjbCzkIM6qRdKBoLPXmKKMiFYnkd6rAoprih3/PrQEB/VsW8OoM8fxn67UDYuyBTqA23MML9q1+ilIZwBC2AQ2UBVOrFXfFl75p6/B5KsiNG9zpgmLCUYuLkxpLQIDAQAB";

	// 服务器异步通知页面路径 需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
	public static String notify_url = "";

	// 页面跳转同步通知页面路径 需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
	public static String return_url = "";

	// 签名方式
	public static String sign_type = "";

	// 调试用，创建TXT日志文件夹路径，见AlipayCore.java类中的logResult(String sWord)打印方法。
	public static String log_path = "C:\\";

	// 字符编码格式 目前支持 gbk 或 utf-8
	public static String input_charset = "utf-8";

	// 支付类型 ，无需修改
	public static String payment_type = "1";

	// 调用的接口名，无需修改
	public static String service = "create_direct_pay_by_user";

	// ↑↑↑↑↑↑↑↑↑↑请在这里配置您的基本信息↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑

	// ↓↓↓↓↓↓↓↓↓↓ 请在这里配置防钓鱼信息，如果没开通防钓鱼功能，为空即可 ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

	// 防钓鱼时间戳 若要使用请调用类文件submit中的query_timestamp函数
	public static String anti_phishing_key = "";

	// 客户端的IP地址 非局域网的外网IP地址，如：221.0.0.1
	public static String exter_invoke_ip = "";

	// ↑↑↑↑↑↑↑↑↑↑请在这里配置防钓鱼信息，如果没开通防钓鱼功能，为空即可 ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
	static {

		Properties properties = null;
		try {
			properties = PropertiesUtils.loadProperties("classpath:direct_alipay.properties");
			partner = (String) properties.get("direct_pay.partner");
			seller_id = (String) properties.get("direct_pay.seller_id");
			private_key = (String) properties.get("direct_pay.private_key");
			alipay_public_key = (String) properties.get("direct_pay.alipay_public_key");
			notify_url = (String) properties.get("direct_pay.notify_url");
			return_url = (String) properties.get("direct_pay.return_url");
			sign_type = (String) properties.get("direct_pay.sign_type");
			anti_phishing_key = (String) properties.get("direct_pay.anti_phishing_key");
			exter_invoke_ip = (String) properties.get("direct_pay.exter_invoke_ip");
		} catch (IOException e) {
			e.printStackTrace();
			logger.warn("未找到资源文件!");
		}

	}

}